<?php

namespace App\Libraries\Entities;

trait HasSort
{
    protected $SortFlag = false;

    public function useSort()
    {
        return $this->SortFlag;
    }

    public function setSort($type)
    {
        $message = '';
        if (!is_null(static::SORT) && !$this->isDirty(static::SORT)) {
            if ($type) {
                $message = $this->Rise();
            } else {
                $message = $this->Decline();
            }
        }

        return $message;
    }

    protected function Decline()
    {
        ++$this->{static::SORT};

        return '排序下降';
    }

    protected function Rise()
    {
        --$this->{static::SORT};

        return '排序上升';
    }
}
